Return to doc.sitecore.com

Valid for Sitecore 5.3
How to protect some of the pages with SSL in Sitecore?

Q:

Some pages and/or sections of a site will require access via HTTPS using 128 bit encryption.  In a standalone ASP.NET site this is configured by setting appropriate options on a folder in IIS. What is the equivalent in Sitecore?

A:

The problem can be solved using a code similar to the sample given below which should be compiled and plugged into the pipelines section.  

1.  Sample Code

namespace MyApp
{
      
public class HTTPS
      {
      
public void Process(HttpRequestArgs args1)
      {
         Sitecore.Data.Items.Item item
= Context.Item;
      
        
if (item.Fields["SSL"].Value == "1")
         {
            
string strSecureURL = "https://";

            strSecureURL
= strSecureURL + WebUtil.GetServerUrl();  
            
            
// ...
            
// transforming retrieved URL and getting the secured one
            
// ...

            WebUtil.Redirect(strSecureURL);
         }
      }
}
}

2.  Processor definition

Place the processor definition just under the ItemResolver processor:

<httpRequestBegin>

        
<processor type="Sitecore.Pipelines.HttpRequest.MediaBouncer, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.StartMeasurements, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.SaveFormAction, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.IgnoreList, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.DatabaseResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.BeginDiagnostics, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.DeviceResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.SecurityResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.CustomHandlers, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.FilterUrlExtensions, Sitecore.Kernel">
          
<param desc="Allowed extensions (comma separated)">aspx</param>
          
<param desc="Blocked extensions (comma separated)">*</param>
        
</processor>
        
<processor type="Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.QueryStringResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.AliasResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.DefaultResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.FileResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel" />
        
<processor type="MyApp.Https, Https" />
        
<processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel" />
        
<processor type="Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel" />

</httpRequestBegin>